package com.weijianhuawen.wjblog.web.convert;

import com.weijianhuawen.wjblog.common.domain.dos.UserDetailDo;
import com.weijianhuawen.wjblog.web.mode.vo.user.FindUserInformationRspVo;
import com.weijianhuawen.wjblog.web.mode.vo.user.RegisterUserReqVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @version: java version 8
 * @Author: weijianhuawen
 * @description:
 * @date: 2024-12-16 12:32
 */

@Mapper
public interface UserConvert {
    // 初始化转换器实例
    UserConvert INSTANCE = Mappers.getMapper(UserConvert.class);

    // 将do转换为vo
    @Mappings({
            @Mapping(target = "registerTime", expression = "java(bean.getCreateTime())"),
            @Mapping(target = "updateDataTime", expression = "java(bean.getUpdateTime())"),
            @Mapping(target = "userId", expression = "java(String.valueOf(bean.getUserId()))")
    })
    FindUserInformationRspVo userDetailDo2InfoVo(UserDetailDo bean);

    // 将vo转换为do
    UserDetailDo vo2UserDetailDo(RegisterUserReqVo bean);
}
